package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Borrow implements Ioperation{

    @Override
    public void work(BookList bookList) {
        Scanner in = new Scanner(System.in);
        System.out.println("输入图书的名字：");
        String name = in.nextLine();
        int currentSize = bookList.getUsedSize();
        for(int i = 0; i < currentSize; i++){
            Book book = bookList.getBooks()[i];
            if(name.equals(book.getName())){
                if(book.isBorrowed()){
                    System.out.println("图书已借阅");
                    return ;
                }else{
                    book.setBorrowed(true);
                    System.out.println("借阅成功");
                    return ;
                }
            }
        }
        System.out.println("图书不存在");
    }
}
